home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / wexmast / wbuttons.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  73 lines

  1. ; $Id: wbuttons.pro,v 1.3 1997/01/15 04:29:15 ali Exp $
  2. ;
  3. ; Copyright (c) 1993-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. ; This is the code for a simple set of widget buttons that perform different
  7. ; actions when they are selected, hence the name 'action buttons'.
  8.  
  9. ; A button's VALUE is equal to the label on the face of the button.
  10. ; In this example, the labels on the buttons are text strings, but
  11. ; buttons can have bitmapped images as labels instead.  For an example
  12. ; of creating a bitmapped button, see the file WBITMAP.PRO.
  13.  
  14.  
  15.  
  16. PRO wbuttons_event, event
  17. ; This procedure is the event handler for a simple set of 'action' buttons.
  18.  
  19. ; When a widget is touched, put its User Value into 'eventval':
  20.  
  21. WIDGET_CONTROL, event.id, GET_UVALUE = eventval
  22.  
  23. ; This CASE statement branches based upon the value of 'eventval:
  24.  
  25. CASE eventval OF
  26.     'GREET'    : PRINT, 'Hello World!'            ;The 'Print a Greeting' button
  27.                             ;has been selected, so print
  28.                             ;a message in the IDL window.
  29.  
  30.     'PRINT'    : PRINT, 'IDL Widgets are Cool.'    ;The 'Print a Message' button
  31.                             ;has been selected, so print
  32.                             ;a message in the IDL window.
  33.  
  34.     'DONE'    : WIDGET_CONTROL, event.top, /DESTROY    ;The 'Done' button has been
  35.                             ;selected, so destroy the widget.
  36. ENDCASE
  37. END
  38.  
  39.  
  40.  
  41. PRO wbuttons, GROUP = GROUP
  42. ; This procedure creates a simple set of buttons.
  43.  
  44. ; Create the top-level base widget:
  45.  
  46. base = WIDGET_BASE(TITLE = 'Action Buttons Example', XSIZE = 350, /COLUMN)
  47.  
  48.  
  49. ; Create three buttons: two 'Print' buttons, and a 'Done' button. 
  50.  
  51. greetbutton = WIDGET_BUTTON(base, $            ;The button belongs to 'base'
  52.                 VALUE = 'Print a Greeting',$;The button label.
  53.                 UVALUE = 'GREET')        ;The button's User Value.
  54.  
  55. printbutton = WIDGET_BUTTON(base, $                     ;The button belongs to 'base'
  56.                             VALUE = 'Print a Message', $;The button label.
  57.                             UVALUE = 'PRINT')           ;The button's User Value.
  58.  
  59. donebutton  = WIDGET_BUTTON(base, $                     ;The button belongs to 'base'
  60.                             VALUE = 'Done', $        ;The button label.
  61.                             UVALUE = 'DONE')        ;The button's User Value.
  62.  
  63.  
  64. ; Realize the widgets:
  65. WIDGET_CONTROL, base, /REALIZE
  66.  
  67. ; Hand off to the XMANAGER:
  68. XMANAGER, 'wbuttons', base, GROUP_LEADER = GROUP, /NO_BLOCK
  69.  
  70. END
  71.  
  72.  
  73.